﻿using RpcCentral.Model;
using RpcCentral.Model.DB;
using SqlSugarHelper;

namespace RpcCentral.DAL.Repository
{
    internal class ServerTransmitConfigDAL : IServerTransmitConfigDAL
    {
        private IRepository<ServerTransmitConfigModel> _Db;
        public ServerTransmitConfigDAL(IRepository<ServerTransmitConfigModel> db)
        {
            _Db = db;
        }

        public ServerTransmitConfig[] Gets(long systemType, long rpcMerId)
        {
            long[] rpcMers = new long[] { rpcMerId, 0 };
            return this._Db.Gets(a => a.SystemTypeId == systemType && rpcMers.Contains(a.RpcMerId) && a.IsEnable, c => new ServerTransmitConfig
            {
                TransmitConfig = c.TransmitConfig,
                Id = c.Id,
                Scheme = c.Scheme,
                SeverId = c.SeverId,
                TransmitType = c.TransmitType,
                VerNum = c.VerNum
            });
        }
    }
}
